Skip to content

Release v4.28.1#24

Merged
mikebarkmin merged 1 commit into
mainfrom
changeset
Jul 20, 2026
Merged

Release v4.28.1#24
mikebarkmin merged 1 commit into
mainfrom
changeset

Conversation

@github-actions

Copy link
Copy Markdown

Fix incorrect math in Operators and Color, found while adding a unit test suite for the library's pure-logic classes (Operators, extensions/math, extensions/shape, extensions/hitbox, extensions/color).

  • Operators.asinOf, Operators.acosOf, Operators.atanOf: these applied the degrees conversion to the input before taking the inverse trig function, and never converted the result back to degrees, so asinOf/acosOf returned NaN for almost any real input, and atanOf returned radians instead of degrees. They now correctly return the degree-valued inverse of sinOf/cosOf/tanOf (e.g. asinOf(1.0) == 90.0).
  • Operators.max(double...): seeded its accumulator with Double.MIN_VALUE (the smallest positive double) instead of Double.NEGATIVE_INFINITY, so it returned the wrong result whenever every input was negative. Fixed to seed with Double.NEGATIVE_INFINITY.
  • Color(double r, double g, double b): passed g twice to setRGB, silently dropping the blue channel and replacing it with the green value. Fixed to pass r, g, b. This also corrects GifRecorder.transparent, which is constructed with this constructor.

Fix Sprite.DIRECTION_RIGHT/DIRECTION_UP/DIRECTION_LEFT/DIRECTION_DOWN (introduced in the previous release) having their degree values swapped relative to how Sprite.move() and setDirection() actually behave. A sprite's default direction is 90, which moves it along +x ("right"), and move()'s trig confirms the real convention — matching real Scratch — is 0 = up, 90 = right, 180 = down, 270 = left. The constants previously claimed 0 = right, 90 = up, 180 = left, 270 = down, the opposite of reality. Also corrected the matching descriptions in setDirection()'s and pointInDirection()'s Javadoc, which had the same swap.

No shipped example or demo used these constants, so this only affects code written against the just-released values.

MapObject.getProperty() now throws a helpful error message naming the missing property and, when available, the properties that do exist on that map object — instead of a bare NoSuchElementException with no context. It also now gives a clear message when the map object has no custom properties at all, rather than a raw NullPointerException. This matches the library's existing beginner-friendly error reporting for missing assets.

@mikebarkmin
mikebarkmin merged commit 156b9ad into main Jul 20, 2026
@github-actions
github-actions Bot deleted the changeset branch July 20, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant